cmake_minimum_required(VERSION 3.12.0)

cmake_policy(SET CMP0074 NEW)

if(WIN32)
  add_compile_options(/wd4819)
  add_compile_options(/D_CRT_SECURE_NO_WARNINGS)
endif()

project(sample VERSION 0.1.0)

find_package(fmt CONFIG REQUIRED)
find_package(DataFrame CONFIG REQUIRED)
find_package(Xlnt CONFIG REQUIRED)
find_path(RAPIDCSV_INCLUDE_DIRS "rapidcsv.h")

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
  add_definitions(-D_DEBUG)
endif()

set(TARGET_NAME sample)

add_executable(${TARGET_NAME})

file(GLOB_RECURSE SOURCES ${CMAKE_SOURCE_DIR}/src/*.cpp)

target_sources(${TARGET_NAME} PRIVATE ${SOURCES})

target_compile_features(${TARGET_NAME} PRIVATE cxx_std_17)

target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_link_libraries(${TARGET_NAME} PRIVATE fmt::fmt-header-only)
target_link_libraries(${TARGET_NAME} PRIVATE DataFrame::DataFrame)
target_include_directories(${TARGET_NAME} PRIVATE ${RAPIDCSV_INCLUDE_DIRS})
target_link_libraries(${TARGET_NAME} PRIVATE xlnt::xlnt)
# target_link_libraries(${TARGET_NAME} PRIVATE -static-libstdc++)

set_target_properties(${TARGET_NAME} PROPERTIES DEBUG_POSTFIX "_d")

set_target_properties(${TARGET_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_DEBUG
                                                "${CMAKE_SOURCE_DIR}/lib")
set_target_properties(${TARGET_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELEASE
                                                "${CMAKE_SOURCE_DIR}/lib")
set_target_properties(${TARGET_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG
                                                "${CMAKE_SOURCE_DIR}/bin")
set_target_properties(${TARGET_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE
                                                "${CMAKE_SOURCE_DIR}/bin")
